<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%String path = request.getContextPath();String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<%--上传应用系统图标 --%>
		<base href="<%=basePath%>">
		<body >
		<meta http-equiv="cache-control" content="no-cache"/>
		<meta http-equiv="expires" content="0"/>    
		<link rel="stylesheet" type="text/css" href="resource/css/artdialog/chrome_.css"/>
		<script type="text/javascript" src="resource/js/jquery-1.7.2.min.js"></script>
		<script type="text/javascript" src="resource/js/jquery.form.js"></script>
		<script type="text/javascript" src="resource/js/artDialog.js"></script>
		<script type="text/javascript" src="resource/js/iframeTools.js"></script>
		<script type="text/javascript">
			$(function(){
				/**显示提示并关闭窗口*/
				function tipclose(status,msg,val){
					if(msg){
						art.dialog.tips(msg);
						if("1" == status){
							var origin = artDialog.open.origin;
							origin.document.getElementById('icon').value = val;
							window.setTimeout(function(){
								art.dialog.close();
							},1500);
						}
					}
				}
				//关闭窗口
				$("#btn_esc").click(function(){
					art.dialog.close();
				});
				/**表单提交*/
				$("#btn_submit").click(function(){
					var _icon = $("#icon").val();//.replace(/(^\s*)|(\s*$)/g,"");
					if("" == _icon){
						art.dialog.tips("请选择系统图标文件！");
						return false;
					}else{
						var _suffix = _icon.substring(_icon.lastIndexOf(".")+1).toUpperCase();
						if(!("JPG" == _suffix || "JPEG" == _suffix || "GIF" == _suffix || "PNG" == _suffix)){
							art.dialog.tips("您选择的系统图标文件格式不支持！");
							return false;
						}
					}
					$("#app_icon_upload_form").ajaxSubmit({
						url:"app/icon/create.json",
						type:"post",
						dataType:"text",
						success:function(data){
							var _json = eval("("+data+")");
							var _msg,_val; 
							if("size_error" == _json.body){
								_msg = "允许上传的图标文件最大100K！";
							}else if("suffix_error" == _json.body){
								_msg = "请上传JPG、GIF、PNG格式文件！";
							}else if("ex_error" == _json.body){
								_msg = "系统图标上传失败！";
							}else if("1" == _json.status){
								_msg = "系统图标上传成功！";
								_val = _json.body;
							}
							tipclose(_json.status,_msg,_val);
						}
					});
				});
				function checkFileSize(filePath,maxSize){
					var image=new Image();    
					image.dynsrc=$(this).val();
					alert(image.fileSize);
					return image.fileSize <= maxSize;
				}
			});
		</script>
		<style type="text/css">
			body{margin:0 auto;padding:0px;font-size:12px;color:#535353;font-family:verdana 黑体;}
			a{text-decoration:none;}
			input{font-family:verdana 黑体;}
		</style>
	</head>
	<body style="margin:0px;padding:0px;overflow: hidden;">
		<div id="container">
    		<form action="app/icon/upload" id="app_icon_upload_form" enctype="multipart/form-data">
    			<table>
    				<tr style="height:15px;"><td></td></tr>
    				<tr>
    					<td style="width:70px;text-align:right;">系统图标:</td>
    					<td><input id="icon" type="file" name="icon" value="浏览..." size="30" title="请上传GIF,PNG,JPG格式且文件大小不超过100K的图标文件！"/></td>
    				</tr>
    				<tr><td style="width:70px;text-align:right;">(图片格式:</td>
    					<td>.jpg .png .gif &nbsp;&nbsp;&nbsp; 图片大小:100kb以内)</td>
    				</tr>
    				<tr >
    					<td style="text-align:right;" colspan="2">
    						<input id="btn_submit" type="button" value="保存"/>
	    					<input id="btn_esc" type="button" value="取消"/>
    					</td>
    				</tr>
    			</table>
			</form>
	    </div>
	</body>
</html>
